package com.paradogs.framework.core.strategy;

import com.paradogs.framework.core.netty.server.PRConnection;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Random;

/**
 * @author: yumi
 * @date: 2023/11/13  13:50
 * @Description: TODO
 */
@Component("gatewayRandomLoadBalancerStrategy")
public class GateRandomLoadBalancerStrategy implements GateLoadBalancerStrategy {
    @Override
    public PRConnection choose(List<PRConnection> nodes) {
        if (nodes.size() == 0) {return null;}
        Random random = new Random();
        return nodes.get(random.nextInt(nodes.size()));
    }
}
